package cn.com.test.common.proxy;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibProxy implements MethodInterceptor {

	@Override
	public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
		before();
		methodProxy.invokeSuper(o, objects);
		after();
		return "success";
	}

	private void before() {
		System.out.println("事务开始---");
	}

	private void after() {
		System.out.println("事务结束---");
	}
}
